package com.app.common.dataDictionary.PO;

import java.util.*;
import com.css.sword.kernel.base.annotation.*;
import com.css.sword.kernel.base.dataElement.*;
import com.css.sword.kernel.base.exception.SwordBaseCheckedException;

import com.app.common.dataDictionary.DE.DE_U_SWDD_ID;
import com.app.common.dataDictionary.DE.DE_USERPRIZE_ID;
import com.app.common.dataDictionary.DE.DE_U_SWDD_SHRXM;
import com.app.common.dataDictionary.DE.DE_U_SWDD_SHRDZ;
import com.app.common.dataDictionary.DE.DE_U_SWDD_SHRLXDH;
import com.app.common.dataDictionary.DE.DE_U_SWDD_SHRYZBM;
import com.app.common.dataDictionary.DE.DE_U_SWDD_STATUS;
import com.app.common.dataDictionary.DE.DE_U_SWDD_OPPTIME;
import com.app.common.dataDictionary.DE.DE_U_SWDD_ZDQRSHSJ;


/**
 * 实物订单表
 */
@PersistObject
public class TUserprizeSwddPO extends AbsPersistObject {
	//private static final long serialVersionUID = -4253632668057144684L;
	private static final long serialVersionUID = 1L;
	private static final Map<String, Integer> fieldIndex = new HashMap<String, Integer>(9);
	private static final BitSet HAS_DEFAULT_VALUE = new BitSet(9);
	
	static{
		fieldIndex.put("uSwddId",0);fieldIndex.put("userprizeId",1);fieldIndex.put("uSwddShrxm",2);fieldIndex.put("uSwddShrdz",3);fieldIndex.put("uSwddShrlxdh",4);fieldIndex.put("uSwddShryzbm",5);fieldIndex.put("uSwddStatus",6);fieldIndex.put("uSwddOpptime",7);fieldIndex.put("uSwddZdqrshsj",8);
	}
	
	/**
	 * 物理表名
	 */
	public static final String TABLE_NAME = "t_userprize_swdd";

	/**
	 * 订单id
	 */
	private DE_U_SWDD_ID uSwddId = DE_U_SWDD_ID.getTemplateInstance();

	/**
	 * 用户奖品id
	 */
	private DE_USERPRIZE_ID userprizeId = DE_USERPRIZE_ID.getTemplateInstance();

	/**
	 * 收货人姓名
	 */
	private DE_U_SWDD_SHRXM uSwddShrxm = DE_U_SWDD_SHRXM.getTemplateInstance();

	/**
	 * 收货人地址
	 */
	private DE_U_SWDD_SHRDZ uSwddShrdz = DE_U_SWDD_SHRDZ.getTemplateInstance();

	/**
	 * 收货人联系电话
	 */
	private DE_U_SWDD_SHRLXDH uSwddShrlxdh = DE_U_SWDD_SHRLXDH.getTemplateInstance();

	/**
	 * 收货人邮政编码
	 */
	private DE_U_SWDD_SHRYZBM uSwddShryzbm = DE_U_SWDD_SHRYZBM.getTemplateInstance();

	/**
	 * 订单状态
	 */
	private DE_U_SWDD_STATUS uSwddStatus = DE_U_SWDD_STATUS.getTemplateInstance();

	/**
	 * 订单操作时间
	 */
	private DE_U_SWDD_OPPTIME uSwddOpptime = DE_U_SWDD_OPPTIME.getTemplateInstance();

	/**
	 * 实物订单自动确认收货时间
	 */
	private DE_U_SWDD_ZDQRSHSJ uSwddZdqrshsj = DE_U_SWDD_ZDQRSHSJ.getTemplateInstance();


	public TUserprizeSwddPO(){
		this.insertState = new BitSet(9);
		this.updateState = new BitSet(9);
	}

	
	/**
	 * 获取 "订单id" 值
	 */	
	public DE_U_SWDD_ID getUSwddId(){
		return  uSwddId;
	}
	
	/**
	 * 设置 "订单id" 值
	 */
	public void setUSwddId(DE_U_SWDD_ID uSwddId) {
		if(uSwddId == null){
			uSwddId= DE_U_SWDD_ID.getTemplateInstance();
		}
		recordChangeFlag(0);
		this.uSwddId = uSwddId;
	}
	
	/**
	 * 获取 "用户奖品id" 值
	 */	
	public DE_USERPRIZE_ID getUserprizeId(){
		return  userprizeId;
	}
	
	/**
	 * 设置 "用户奖品id" 值
	 */
	public void setUserprizeId(DE_USERPRIZE_ID userprizeId) {
		if(userprizeId == null){
			userprizeId= DE_USERPRIZE_ID.getTemplateInstance();
		}
		recordChangeFlag(1);
		this.userprizeId = userprizeId;
	}
	
	/**
	 * 获取 "收货人姓名" 值
	 */	
	public DE_U_SWDD_SHRXM getUSwddShrxm(){
		return  uSwddShrxm;
	}
	
	/**
	 * 设置 "收货人姓名" 值
	 */
	public void setUSwddShrxm(DE_U_SWDD_SHRXM uSwddShrxm) {
		if(uSwddShrxm == null){
			uSwddShrxm= DE_U_SWDD_SHRXM.getTemplateInstance();
		}
		recordChangeFlag(2);
		this.uSwddShrxm = uSwddShrxm;
	}
	
	/**
	 * 获取 "收货人地址" 值
	 */	
	public DE_U_SWDD_SHRDZ getUSwddShrdz(){
		return  uSwddShrdz;
	}
	
	/**
	 * 设置 "收货人地址" 值
	 */
	public void setUSwddShrdz(DE_U_SWDD_SHRDZ uSwddShrdz) {
		if(uSwddShrdz == null){
			uSwddShrdz= DE_U_SWDD_SHRDZ.getTemplateInstance();
		}
		recordChangeFlag(3);
		this.uSwddShrdz = uSwddShrdz;
	}
	
	/**
	 * 获取 "收货人联系电话" 值
	 */	
	public DE_U_SWDD_SHRLXDH getUSwddShrlxdh(){
		return  uSwddShrlxdh;
	}
	
	/**
	 * 设置 "收货人联系电话" 值
	 */
	public void setUSwddShrlxdh(DE_U_SWDD_SHRLXDH uSwddShrlxdh) {
		if(uSwddShrlxdh == null){
			uSwddShrlxdh= DE_U_SWDD_SHRLXDH.getTemplateInstance();
		}
		recordChangeFlag(4);
		this.uSwddShrlxdh = uSwddShrlxdh;
	}
	
	/**
	 * 获取 "收货人邮政编码" 值
	 */	
	public DE_U_SWDD_SHRYZBM getUSwddShryzbm(){
		return  uSwddShryzbm;
	}
	
	/**
	 * 设置 "收货人邮政编码" 值
	 */
	public void setUSwddShryzbm(DE_U_SWDD_SHRYZBM uSwddShryzbm) {
		if(uSwddShryzbm == null){
			uSwddShryzbm= DE_U_SWDD_SHRYZBM.getTemplateInstance();
		}
		recordChangeFlag(5);
		this.uSwddShryzbm = uSwddShryzbm;
	}
	
	/**
	 * 获取 "订单状态" 值
	 */	
	public DE_U_SWDD_STATUS getUSwddStatus(){
		return  uSwddStatus;
	}
	
	/**
	 * 设置 "订单状态" 值
	 */
	public void setUSwddStatus(DE_U_SWDD_STATUS uSwddStatus) {
		if(uSwddStatus == null){
			uSwddStatus= DE_U_SWDD_STATUS.getTemplateInstance();
		}
		recordChangeFlag(6);
		this.uSwddStatus = uSwddStatus;
	}
	
	/**
	 * 获取 "订单操作时间" 值
	 */	
	public DE_U_SWDD_OPPTIME getUSwddOpptime(){
		return  uSwddOpptime;
	}
	
	/**
	 * 设置 "订单操作时间" 值
	 */
	public void setUSwddOpptime(DE_U_SWDD_OPPTIME uSwddOpptime) {
		if(uSwddOpptime == null){
			uSwddOpptime= DE_U_SWDD_OPPTIME.getTemplateInstance();
		}
		recordChangeFlag(7);
		this.uSwddOpptime = uSwddOpptime;
	}
	
	/**
	 * 获取 "实物订单自动确认收货时间" 值
	 */	
	public DE_U_SWDD_ZDQRSHSJ getUSwddZdqrshsj(){
		return  uSwddZdqrshsj;
	}
	
	/**
	 * 设置 "实物订单自动确认收货时间" 值
	 */
	public void setUSwddZdqrshsj(DE_U_SWDD_ZDQRSHSJ uSwddZdqrshsj) {
		if(uSwddZdqrshsj == null){
			uSwddZdqrshsj= DE_U_SWDD_ZDQRSHSJ.getTemplateInstance();
		}
		recordChangeFlag(8);
		this.uSwddZdqrshsj = uSwddZdqrshsj;
	}


	@Override
	public BaseDataElement<?>[] fields(){
		return new BaseDataElement<?>[] {uSwddId,userprizeId,uSwddShrxm,uSwddShrdz,uSwddShrlxdh,uSwddShryzbm,uSwddStatus,uSwddOpptime,uSwddZdqrshsj};
	}
	
	@Override
	public String[] fieldNames() {
		return new String[]{"uSwddId","userprizeId","uSwddShrxm","uSwddShrdz","uSwddShrlxdh","uSwddShryzbm","uSwddStatus","uSwddOpptime","uSwddZdqrshsj"};
	}
	
	@Override
	public BaseDataElement<?> getFieldValue(String fieldName)  {
		final Integer index = fieldIndex.get(fieldName);
		if (index == null) {
			throw new IllegalArgumentException("PO对象中没有" + fieldName + "字段");
		}
		switch (index) {
		case 0 : return uSwddId;
		case 1 : return userprizeId;
		case 2 : return uSwddShrxm;
		case 3 : return uSwddShrdz;
		case 4 : return uSwddShrlxdh;
		case 5 : return uSwddShryzbm;
		case 6 : return uSwddStatus;
		case 7 : return uSwddOpptime;
		case 8 : return uSwddZdqrshsj;
 
		default:
			throw new IllegalArgumentException("PO对象中没有" + fieldName + "字段");
		}
	}
	
	@Override
	public TUserprizeSwddPO setFieldValue(String fieldName, Object fieldValue) throws SwordBaseCheckedException {
		if (fieldValue != null && !(fieldValue instanceof BaseDataElement<?>)) {
			throw new SwordBaseCheckedException("字段值类型不是DataElelement子类型");
		}

		final Integer index = fieldIndex.get(fieldName);
		if (index == null) {
			throw new SwordBaseCheckedException("PO对象中没有" + fieldName + "字段");
		}

		switch (index) {

				case 0 : {
					if (fieldValue == null) {
						setUSwddId(null);
					} else {
						setUSwddId((DE_U_SWDD_ID) fieldValue);
					}
					return this;
				}
				
				case 1 : {
					if (fieldValue == null) {
						setUserprizeId(null);
					} else {
						setUserprizeId((DE_USERPRIZE_ID) fieldValue);
					}
					return this;
				}
				
				case 2 : {
					if (fieldValue == null) {
						setUSwddShrxm(null);
					} else {
						setUSwddShrxm((DE_U_SWDD_SHRXM) fieldValue);
					}
					return this;
				}
				
				case 3 : {
					if (fieldValue == null) {
						setUSwddShrdz(null);
					} else {
						setUSwddShrdz((DE_U_SWDD_SHRDZ) fieldValue);
					}
					return this;
				}
				
				case 4 : {
					if (fieldValue == null) {
						setUSwddShrlxdh(null);
					} else {
						setUSwddShrlxdh((DE_U_SWDD_SHRLXDH) fieldValue);
					}
					return this;
				}
				
				case 5 : {
					if (fieldValue == null) {
						setUSwddShryzbm(null);
					} else {
						setUSwddShryzbm((DE_U_SWDD_SHRYZBM) fieldValue);
					}
					return this;
				}
				
				case 6 : {
					if (fieldValue == null) {
						setUSwddStatus(null);
					} else {
						setUSwddStatus((DE_U_SWDD_STATUS) fieldValue);
					}
					return this;
				}
				
				case 7 : {
					if (fieldValue == null) {
						setUSwddOpptime(null);
					} else {
						setUSwddOpptime((DE_U_SWDD_OPPTIME) fieldValue);
					}
					return this;
				}
				
				case 8 : {
					if (fieldValue == null) {
						setUSwddZdqrshsj(null);
					} else {
						setUSwddZdqrshsj((DE_U_SWDD_ZDQRSHSJ) fieldValue);
					}
					return this;
				}
				
		default:
			throw new SwordBaseCheckedException("PO对象中没有" + fieldName + "字段");
		}
	
	}

	@Override
	protected TUserprizeSwddPO clone() {
		TUserprizeSwddPO t = new TUserprizeSwddPO();
		
		t.setUSwddId(this.uSwddId);
		t.setUserprizeId(this.userprizeId);
		t.setUSwddShrxm(this.uSwddShrxm);
		t.setUSwddShrdz(this.uSwddShrdz);
		t.setUSwddShrlxdh(this.uSwddShrlxdh);
		t.setUSwddShryzbm(this.uSwddShryzbm);
		t.setUSwddStatus(this.uSwddStatus);
		t.setUSwddOpptime(this.uSwddOpptime);
		t.setUSwddZdqrshsj(this.uSwddZdqrshsj);

		return t;
	}

	@Override
	public TUserprizeSwddPO loadMap(Map<String, Object> dataMap) throws SwordBaseCheckedException {
		Object value = null;

		if(dataMap.containsKey("uSwddId")){
			value = dataMap.get("uSwddId");
			
			if (value == null) {
				this.setUSwddId(null);
			} else {
				if (value instanceof DE_U_SWDD_ID) {
					this.setUSwddId((DE_U_SWDD_ID) value);
				}
			    else {
					this.setUSwddId(new DE_U_SWDD_ID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("userprizeId")){
			value = dataMap.get("userprizeId");
			
			if (value == null) {
				this.setUserprizeId(null);
			} else {
				if (value instanceof DE_USERPRIZE_ID) {
					this.setUserprizeId((DE_USERPRIZE_ID) value);
				}
			    else {
					this.setUserprizeId(new DE_USERPRIZE_ID(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("uSwddShrxm")){
			value = dataMap.get("uSwddShrxm");
			
			if (value == null) {
				this.setUSwddShrxm(null);
			} else {
				if (value instanceof DE_U_SWDD_SHRXM) {
					this.setUSwddShrxm((DE_U_SWDD_SHRXM) value);
				}
			    else {
					this.setUSwddShrxm(new DE_U_SWDD_SHRXM(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("uSwddShrdz")){
			value = dataMap.get("uSwddShrdz");
			
			if (value == null) {
				this.setUSwddShrdz(null);
			} else {
				if (value instanceof DE_U_SWDD_SHRDZ) {
					this.setUSwddShrdz((DE_U_SWDD_SHRDZ) value);
				}
			    else {
					this.setUSwddShrdz(new DE_U_SWDD_SHRDZ(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("uSwddShrlxdh")){
			value = dataMap.get("uSwddShrlxdh");
			
			if (value == null) {
				this.setUSwddShrlxdh(null);
			} else {
				if (value instanceof DE_U_SWDD_SHRLXDH) {
					this.setUSwddShrlxdh((DE_U_SWDD_SHRLXDH) value);
				}
			    else {
					this.setUSwddShrlxdh(new DE_U_SWDD_SHRLXDH(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("uSwddShryzbm")){
			value = dataMap.get("uSwddShryzbm");
			
			if (value == null) {
				this.setUSwddShryzbm(null);
			} else {
				if (value instanceof DE_U_SWDD_SHRYZBM) {
					this.setUSwddShryzbm((DE_U_SWDD_SHRYZBM) value);
				}
			    else {
					this.setUSwddShryzbm(new DE_U_SWDD_SHRYZBM(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("uSwddStatus")){
			value = dataMap.get("uSwddStatus");
			
			if (value == null) {
				this.setUSwddStatus(null);
			} else {
				if (value instanceof DE_U_SWDD_STATUS) {
					this.setUSwddStatus((DE_U_SWDD_STATUS) value);
				}
			    else {
					this.setUSwddStatus(new DE_U_SWDD_STATUS(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("uSwddOpptime")){
			value = dataMap.get("uSwddOpptime");
			
			if (value == null) {
				this.setUSwddOpptime(null);
			} else {
				if (value instanceof DE_U_SWDD_OPPTIME) {
					this.setUSwddOpptime((DE_U_SWDD_OPPTIME) value);
				}
				else if(value instanceof java.util.Date){
					this.setUSwddOpptime(new DE_U_SWDD_OPPTIME((java.util.Date)value));
				}
			    else {
					this.setUSwddOpptime(new DE_U_SWDD_OPPTIME(value.toString()));
				}
			}
		}

		if(dataMap.containsKey("uSwddZdqrshsj")){
			value = dataMap.get("uSwddZdqrshsj");
			
			if (value == null) {
				this.setUSwddZdqrshsj(null);
			} else {
				if (value instanceof DE_U_SWDD_ZDQRSHSJ) {
					this.setUSwddZdqrshsj((DE_U_SWDD_ZDQRSHSJ) value);
				}
				else if(value instanceof java.util.Date){
					this.setUSwddZdqrshsj(new DE_U_SWDD_ZDQRSHSJ((java.util.Date)value));
				}
			    else {
					this.setUSwddZdqrshsj(new DE_U_SWDD_ZDQRSHSJ(value.toString()));
				}
			}
		}

		return this;
	}
	
	@Override
	public Map<String,Object> toMap() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("uSwddId", uSwddId);
		dataMap.put("userprizeId", userprizeId);
		dataMap.put("uSwddShrxm", uSwddShrxm);
		dataMap.put("uSwddShrdz", uSwddShrdz);
		dataMap.put("uSwddShrlxdh", uSwddShrlxdh);
		dataMap.put("uSwddShryzbm", uSwddShryzbm);
		dataMap.put("uSwddStatus", uSwddStatus);
		dataMap.put("uSwddOpptime", uSwddOpptime);
		dataMap.put("uSwddZdqrshsj", uSwddZdqrshsj);
		
		return dataMap;
	}
	
	@Override
	public Map<String,Object> toMapWithDEValue() {
		Map<String,Object> dataMap = new HashMap<String,Object>();

		dataMap.put("uSwddId", (uSwddId==null?null:uSwddId.value));
		dataMap.put("userprizeId", (userprizeId==null?null:userprizeId.value));
		dataMap.put("uSwddShrxm", (uSwddShrxm==null?null:uSwddShrxm.value));
		dataMap.put("uSwddShrdz", (uSwddShrdz==null?null:uSwddShrdz.value));
		dataMap.put("uSwddShrlxdh", (uSwddShrlxdh==null?null:uSwddShrlxdh.value));
		dataMap.put("uSwddShryzbm", (uSwddShryzbm==null?null:uSwddShryzbm.value));
		dataMap.put("uSwddStatus", (uSwddStatus==null?null:uSwddStatus.value));
		dataMap.put("uSwddOpptime", (uSwddOpptime==null?null:uSwddOpptime.value));
		dataMap.put("uSwddZdqrshsj", (uSwddZdqrshsj==null?null:uSwddZdqrshsj.value));
		
		return dataMap;
	}
	
	@Override
	public TUserprizeSwddPO newInstance() {
		return new TUserprizeSwddPO();
	}
	
	@Override
	public String getTableName(){
		return TABLE_NAME;
	}
	
	@Override
	public BaseDataElement<?>[] getPrimaryKey() {
		return new BaseDataElement<?>[]{uSwddId};
	}

	@Override
	public void checkNotNull(byte sqlType) throws SwordBaseCheckedException {
		StringBuilder errorMsg = new StringBuilder();
		// insert
		if (sqlType == 0) {
				//只校验不可为空但又没有默认值的字段
				if (uSwddId.value == null && !HAS_DEFAULT_VALUE.get(0)) {
					errorMsg.append("字段uSwddId不允许为空\n");
				}
				if (userprizeId.value == null && !HAS_DEFAULT_VALUE.get(1)) {
					errorMsg.append("字段userprizeId不允许为空\n");
				}
				if (uSwddShrxm.value == null && !HAS_DEFAULT_VALUE.get(2)) {
					errorMsg.append("字段uSwddShrxm不允许为空\n");
				}
				if (uSwddShrdz.value == null && !HAS_DEFAULT_VALUE.get(3)) {
					errorMsg.append("字段uSwddShrdz不允许为空\n");
				}
				if (uSwddShrlxdh.value == null && !HAS_DEFAULT_VALUE.get(4)) {
					errorMsg.append("字段uSwddShrlxdh不允许为空\n");
				}
				if (uSwddStatus.value == null && !HAS_DEFAULT_VALUE.get(6)) {
					errorMsg.append("字段uSwddStatus不允许为空\n");
				}

		}
		// update
		else if (sqlType == 1) {
		if (updateState.get(0) && uSwddId.value == null) {
			errorMsg.append("字段uSwddId不允许为空\n");
		}
		if (updateState.get(1) && userprizeId.value == null) {
			errorMsg.append("字段userprizeId不允许为空\n");
		}
		if (updateState.get(2) && uSwddShrxm.value == null) {
			errorMsg.append("字段uSwddShrxm不允许为空\n");
		}
		if (updateState.get(3) && uSwddShrdz.value == null) {
			errorMsg.append("字段uSwddShrdz不允许为空\n");
		}
		if (updateState.get(4) && uSwddShrlxdh.value == null) {
			errorMsg.append("字段uSwddShrlxdh不允许为空\n");
		}
		if (updateState.get(6) && uSwddStatus.value == null) {
			errorMsg.append("字段uSwddStatus不允许为空\n");
		}

		}
		
		if (errorMsg.length() > 0) {
			errorMsg.setLength(errorMsg.length() - 1);
			throw new SwordBaseCheckedException(errorMsg.toString());
		}
	}

	@Override
	public void updateLrrq(DateDE lrrq) {
	}

	@Override
	public void updateXgrq(DateDE xgrq) {
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();
		str.append("uSwddId:").append(uSwddId.value!=null?uSwddId:"").append(" ").append("userprizeId:").append(userprizeId.value!=null?userprizeId:"").append(" ").append("uSwddShrxm:").append(uSwddShrxm.value!=null?uSwddShrxm:"").append(" ").append("uSwddShrdz:").append(uSwddShrdz.value!=null?uSwddShrdz:"").append(" ").append("uSwddShrlxdh:").append(uSwddShrlxdh.value!=null?uSwddShrlxdh:"").append(" ").append("uSwddShryzbm:").append(uSwddShryzbm.value!=null?uSwddShryzbm:"").append(" ").append("uSwddStatus:").append(uSwddStatus.value!=null?uSwddStatus:"").append(" ").append("uSwddOpptime:").append(uSwddOpptime.value!=null?uSwddOpptime:"").append(" ").append("uSwddZdqrshsj:").append(uSwddZdqrshsj.value!=null?uSwddZdqrshsj:"").append(" ");
		return str.toString();
	}
	
}
